package com.project.service.imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmailBean;
import com.project.bean.InBoxBean;
import com.project.mapper.IEmailMapper;
import com.project.mapper.IInboxMapper;
import com.project.service.IInboxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
@Service
@Transactional
public class InboxServiceImp implements IInboxService {
    @Autowired
    private IInboxMapper mapper;
    @Override
    public PageInfo<InBoxBean> cutPageByItem(Integer pageNum, Integer userId, String title, LocalDate startTim, LocalDate endTim) {
        PageHelper.startPage(pageNum,2);
        PageInfo<InBoxBean> pg = PageInfo.of(mapper.cutPageByItem(userId,title,startTim,endTim));
        return pg;
    }

    @Override
    public EmailBean findById(Integer inboxId) {
        EmailBean emailBean =mapper.findById(inboxId);
        mapper.upd(inboxId);
        return emailBean;
    }

    @Override
    public void del(Integer inboxId) {
        mapper.del(inboxId);
    }
}
